package com.ofcoder.algorithmsamples.seata.starter;

import com.ofcoder.algorithmsamples.seata.ApplicationKeeper;
import com.ofcoder.algorithmsamples.seata.dubbo.api.AccountService;
import com.ofcoder.algorithmsamples.seata.dubbo.api.StorageService;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jdbc.core.JdbcTemplate;

/**
 * @author: lyy
 * created in 2021/5/27
 */
public class AccountStarter {

    public static void main(String[] args) {
        ClassPathXmlApplicationContext accountContext = new ClassPathXmlApplicationContext(new String[]{"spring/dubbo-account-service.xml"});
        accountContext.getBean("accountService");
        JdbcTemplate accountJdbcTemplate = (JdbcTemplate) accountContext.getBean("jdbcTemplate");
        accountJdbcTemplate.update("delete from seata_account where user_id = 'U100001'");
        accountJdbcTemplate.update("insert into seata_account(user_id, balance) values ('U100001', 999)");

        new ApplicationKeeper(accountContext).keep();
    }

}
